*** Settings ***
Documentation     RobotFramework 测试用例，用于验证用户 CRUD 接口功能
Library           RequestsLibrary
Library           Collections

*** Variables ***
${BASE_URL}       http://127.0.0.1:5000

*** Test Cases ***
测试首页访问是否正常
    Create Session    test_session    ${BASE_URL}
    ${response}=      GET On Session    test_session    /
    Should Be Equal As Strings    ${response.status_code}    200
    Should Contain    ${response.text}    id
    Should Contain    ${response.text}    name

测试搜索功能
    Create Session    test_session    ${BASE_URL}
    ${params}=        Create Dictionary    keyword=test
    ${response}=      GET On Session    test_session    /search    params=${params}
    Should Be Equal As Strings    ${response.status_code}    200
    Should Contain    ${response.text}    id
    Should Contain    ${response.text}    name

测试新增用户功能
    Create Session    test_session    ${BASE_URL}
    ${data}=          Create Dictionary    name=测试增加用户_robot    age=21    gender=女    phone=6666666666
    ${response}=      POST On Session    test_session    /add    data=${data}
    Should Be Equal As Strings    ${response.status_code}    200

测试编辑用户功能
    Create Session    test_session    ${BASE_URL}
    ${data}=          Create Dictionary    id=3    name=测试更新用户_robot    age=28    gender=女    phone=01102203445
    ${response}=      POST On Session    test_session    /edit    data=${data}
    Should Be Equal As Strings    ${response.status_code}    200

测试删除用户功能
    Create Session    test_session    ${BASE_URL}
    ${response}=      GET On Session    test_session    /remove/13/
    Should Be Equal As Strings    ${response.status_code}    200
